package com.baylor.server.business.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.baylor.server.business.entity.UserInfo;

public interface UserInfoRespository extends PagingAndSortingRepository<UserInfo,Integer>,JpaSpecificationExecutor<UserInfo>{
	
	@Query("from UserInfo u where (u.userPhone=?1 or u.userEmail=?1) and u.userPassword=?2 and u.userType=?3 and u.userState<>3")
	public UserInfo appLogin(String userLoginName, String userPassword, String userType);

	@Query("from UserInfo where userPhone=?1")
	public List<UserInfo> findUserByPhone(String userPhone);

	@Query("from UserInfo where userPhone=?2 and userEmail=?1")
	public UserInfo findUserByPhoneAndEmail(String userEmail, String userPhone);

	@Query("from UserInfo where userEmail=?1")
	public List<UserInfo> findEmail(String userEmail);
	
	@Query("from UserInfo u where u.industry=?1 and u.zhOren=1")
	public List<UserInfo>  getUserInfoByIndustry(String industry);
	
	@Query("from UserInfo u where u.zhOren=1")
	public List<UserInfo>  getZhUserInfo();
	
	//非查询sql语句需添加此注解，以示更新操作
	@Modifying
	@Query("from UserInfo u")
	public List<UserInfo>  getAllUser();

	@Query("from UserInfo u where u.userRegister>=?1 and u.userRegister<=?2 and u.userType=?3")
	public List<UserInfo>  getUserByTime(String startTime,String endTime,String userType);
}
